﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Common.Service;
using Common.Contract.DataCenter;
using Common.Contract.DataCenter.Request;
using Common.Contract.Customer;
using Common.Contract.Customer.Request;
using Common.Contract;
using ModernChannel.Configuration;
using Common.Contract.SaleOut;
using Common.Contract.SaleOut.Request;
using Common.Contract.Warranty.Request;
using Common.Contract.Warranty;

namespace ModernChannel.Test
{
    [TestClass]
    public class SynchronizeShopInfo_Test : TestBase
    {
        [TestMethod]
        public void SynchronizeRegion_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeRegion_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestRegions = new SearchRegionsRequest { Header = header, TransferFlag = false };
                var responseRegions = serviceClientCustomer.Proxy.SearchRegions(requestRegions);
                Assert.IsTrue(responseRegions.IsSuccess);
                if (responseRegions.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var region in responseRegions.Records)
                        {
                            SynchronizeRegionRequest request = new SynchronizeRegionRequest
                            {
                                Header = header,
                                Record = region
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeRegion(request);
                            Assert.IsTrue(response.IsSuccess);

                            region.TransferFlag = true;
                            var requestUpdateRegion = new UpdateRegionRequest { Header = header, Record = region };
                            var responseUpdateRegion = serviceClientCustomer.Proxy.UpdateRegion(requestUpdateRegion);
                            Assert.IsTrue(responseUpdateRegion.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeProvince_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeProvince_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestRegions = new SearchProvincesRequest { Header = header, TransferFlag = false };
                var responseRegions = serviceClientCustomer.Proxy.SearchProvinces(requestRegions);
                Assert.IsTrue(responseRegions.IsSuccess);
                if (responseRegions.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var province in responseRegions.Records)
                        {
                            SynchronizeProvinceRequest request = new SynchronizeProvinceRequest
                            {
                                Header = header,
                                Record = province
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeProvince(request);
                            Assert.IsTrue(response.IsSuccess);

                            province.TransferFlag = true;
                            var requestUpdateRegion = new UpdateProvinceRequest { Header = header, Record = province };
                            var responseUpdateRegion = serviceClientCustomer.Proxy.UpdateProvince(requestUpdateRegion);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeDistrict_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeDistrict_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestRegions = new SearchDistrictsRequest { Header = header };
                var responseRegions = serviceClientCustomer.Proxy.SearchDistricts(requestRegions);
                Assert.IsTrue(responseRegions.IsSuccess);
                if (responseRegions.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var district in responseRegions.Records)
                        {
                            SynchronizeDistrictRequest request = new SynchronizeDistrictRequest
                            {
                                Header = header,
                                Record = district
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeDistrict(request);
                            Assert.IsTrue(response.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeShopInfo_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeShopInfo_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestRegions = new SearchShopInfosRequest { Header = header, TransferFlag = false };
                var responseRegions = serviceClientCustomer.Proxy.SearchShopInfo(requestRegions);
                Assert.IsTrue(responseRegions.IsSuccess);
                if (responseRegions.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var shop in responseRegions.Records)
                        {
                            SynchronizeShopRequest request = new SynchronizeShopRequest
                            {
                                Header = header,
                                Record = shop
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeShop(request);
                            Assert.IsTrue(response.IsSuccess);

                            shop.TransferFlag = true;
                            var requestUpdateShop = new UpdateShopInfoRequest { Header = header, Record = shop };
                            var responseUpdateShop = serviceClientCustomer.Proxy.UpdateShopInfo(requestUpdateShop);
                            Assert.IsTrue(responseUpdateShop.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeShopCell_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInf_Test.SynchronizeShopCell_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestRegions = new SearchShopCellsRequest { Header = header, TransferFlag = false };
                var responseRegions = serviceClientCustomer.Proxy.SearchShopCell(requestRegions);
                Assert.IsTrue(responseRegions.IsSuccess);
                if (responseRegions.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var shop in responseRegions.Records)
                        {
                            SynchronizeShopCellRequest request = new SynchronizeShopCellRequest
                            {
                                Header = header,
                                Record = shop
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeShopCell(request);
                            Assert.IsTrue(response.IsSuccess);

                            shop.TransferFlag = true;
                            var requestUpdateShop = new UpdateShopCellRequest { Header = header, Record = shop };
                            var responseUpdateShop = serviceClientCustomer.Proxy.UpdateShopCell(requestUpdateShop);
                            Assert.IsTrue(responseUpdateShop.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeModelCat_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeModelCat_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestRegions = new SearchModelCatRequest { Header = header, TransferFlag = false };
                var responseRegions = serviceClientCustomer.Proxy.SearchModelCat(requestRegions);
                Assert.IsTrue(responseRegions.IsSuccess);
                if (responseRegions.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var modelCat in responseRegions.Records)
                        {
                            SynchronizeModelCatRequest request = new SynchronizeModelCatRequest
                            {
                                Header = header,
                                Record = modelCat
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeModel(request);
                            Assert.IsTrue(response.IsSuccess);

                            modelCat.TransferFlag = true;
                            var requestUpdateModel = new UpdateModelCatRequest { Header = header, Record = modelCat };
                            var responseUpdateModel = serviceClientCustomer.Proxy.UpdateModelCat(requestUpdateModel);
                            Assert.IsTrue(responseUpdateModel.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeCdcHist_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeCdcHist_Success"
            };

            using (ServiceClient<ISaleOut> serviceClientCustomer = new ServiceClient<ISaleOut>())
            {
                //1.Get all regions
                var requestCdcHist = new SearchCdcHistRequest { Header = header, TransferFlag = false };
                var responseCdcHist = serviceClientCustomer.Proxy.SearchCdcHistory(requestCdcHist);
                Assert.IsTrue(responseCdcHist.IsSuccess);
                if (responseCdcHist.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var cdcHist in responseCdcHist.Records)
                        {
                            SynchronizeCdcHistoryRequest request = new SynchronizeCdcHistoryRequest
                            {
                                Header = header,
                                Record = cdcHist
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeCdcHistory(request);
                            Assert.IsTrue(response.IsSuccess);

                            cdcHist.TransferFlag = true;
                            var requestUpdateCdcHist = new UpdateCdcHistRequest { Header = header, Record = cdcHist };
                            var responseUpdateCdcHist = serviceClientCustomer.Proxy.UpdateCdcHistory(requestUpdateCdcHist);
                            Assert.IsTrue(responseUpdateCdcHist.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeRdcHist_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeRdcHist_Success"
            };

            using (ServiceClient<ISaleOut> serviceClientCustomer = new ServiceClient<ISaleOut>())
            {
                //1.Get all regions
                var requestRdcHist = new SearchRdcHistRequest { Header = header, TransferFlag = false };
                var responseRdcHist = serviceClientCustomer.Proxy.SearchRdcHistory(requestRdcHist);
                Assert.IsTrue(responseRdcHist.IsSuccess);
                if (responseRdcHist.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var rdcHist in responseRdcHist.Records)
                        {
                            SynchronizeRdcHistoryRequest request = new SynchronizeRdcHistoryRequest
                            {
                                Header = header,
                                Record = rdcHist
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeRdcHistory(request);
                            Assert.IsTrue(response.IsSuccess);

                            rdcHist.TransferFlag = true;
                            var requestUpdateRdcHist = new UpdateRdcHistRequest { Header = header, Record = rdcHist };
                            var responseUpdateRdcHist = serviceClientCustomer.Proxy.UpdateRdcHistory(requestUpdateRdcHist);
                            Assert.IsTrue(responseUpdateRdcHist.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizePndHist_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizePndHist_Success"
            };

            using (ServiceClient<IWarranty> serviceClientCustomer = new ServiceClient<IWarranty>())
            {
                //1.Get all regions
                var requestPndHist = new SearchPndHistRequest { Header = header, TransferFlag = false };
                var responsePndHist = serviceClientCustomer.Proxy.SearchPndHistory(requestPndHist);
                Assert.IsTrue(responsePndHist.IsSuccess);
                if (responsePndHist.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var PndHist in responsePndHist.Records)
                        {
                            SynchronizePndHistoryRequest request = new SynchronizePndHistoryRequest
                            {
                                Header = header,
                                Record = PndHist
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizePndHistory(request);
                            Assert.IsTrue(response.IsSuccess);

                            PndHist.TransferFlag = true;
                            var requestUpdatePndHist = new UpdatePndHistRequest { Header = header, Record = PndHist };
                            var responseUpdatePndHist = serviceClientCustomer.Proxy.UpdatePndHistory(requestUpdatePndHist);
                            Assert.IsTrue(responseUpdatePndHist.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeWarrantyHistory_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeWarrantyHistory_Success"
            };

            using (ServiceClient<IWarranty> serviceClientCustomer = new ServiceClient<IWarranty>())
            {
                //1.Get all regions
                var requestWarrantyHistory = new SearchWarrantyHistoryRequest { Header = header, TransferFlag = false };
                var responseWarrantyHistory = serviceClientCustomer.Proxy.SearchWarrantyHistory(requestWarrantyHistory);
                Assert.IsTrue(responseWarrantyHistory.IsSuccess);
                if (responseWarrantyHistory.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var WarrantyHistory in responseWarrantyHistory.Records)
                        {
                            SynchronizeWarrantyHistoryRequest request = new SynchronizeWarrantyHistoryRequest
                            {
                                Header = header,
                                Record = WarrantyHistory
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeWarrantyHistory(request);
                            Assert.IsTrue(response.IsSuccess);

                            WarrantyHistory.TransferFlag = true;
                            var requestUpdateWarrantyHistory = new UpdateWarrantyHistoryRequest { Header = header, Record = WarrantyHistory };
                            var responseUpdateWarrantyHistory = serviceClientCustomer.Proxy.UpdateWarrantyHistoryory(requestUpdateWarrantyHistory);
                            Assert.IsTrue(responseUpdateWarrantyHistory.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeWarrantyMaster_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeWarrantyMaster_Success"
            };

            using (ServiceClient<IWarranty> serviceClientCustomer = new ServiceClient<IWarranty>())
            {
                //1.Get all regions
                var requestWarrantyMaster = new SearchWarrantyMasterRequest { Header = header, TransferFlag = false };
                var responseWarrantyMaster = serviceClientCustomer.Proxy.SearchWarrantyMaster(requestWarrantyMaster);
                Assert.IsTrue(responseWarrantyMaster.IsSuccess);
                if (responseWarrantyMaster.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var WarrantyMaster in responseWarrantyMaster.Records)
                        {
                            SynchronizeWarrantyMasterRequest request = new SynchronizeWarrantyMasterRequest
                            {
                                Header = header,
                                Record = WarrantyMaster
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeWarrantyMaster(request);
                            Assert.IsTrue(response.IsSuccess);

                            WarrantyMaster.TransferFlag = true;
                            var requestUpdateWarrantyMaster = new UpdateWarrantyMasterRequest { Header = header, Record = WarrantyMaster };
                            var responseUpdateWarrantyMaster = serviceClientCustomer.Proxy.UpdateWarrantyMaster(requestUpdateWarrantyMaster);
                            Assert.IsTrue(responseUpdateWarrantyMaster.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeWarrantyMessage_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeWarrantyMessage_Success"
            };

            using (ServiceClient<IWarranty> serviceClientCustomer = new ServiceClient<IWarranty>())
            {
                //1.Get all regions
                var requestWarrantyMessage = new SearchWarrantyMessageRequest { Header = header, TransferFlag = false };
                var responseWarrantyMessage = serviceClientCustomer.Proxy.SearchWarrantyMessage(requestWarrantyMessage);
                Assert.IsTrue(responseWarrantyMessage.IsSuccess);
                if (responseWarrantyMessage.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var WarrantyMessage in responseWarrantyMessage.Records)
                        {
                            SynchronizeWarrantyMessageRequest request = new SynchronizeWarrantyMessageRequest
                            {
                                Header = header,
                                Record = WarrantyMessage
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeWarrantyMessage(request);
                            Assert.IsTrue(response.IsSuccess);

                            WarrantyMessage.TransferFlag = true;
                            var requestUpdateWarrantyMessage = new UpdateWarrantyMessageRequest { Header = header, Record = WarrantyMessage };
                            var responseUpdateWarrantyMessage = serviceClientCustomer.Proxy.UpdateWarrantyMessage(requestUpdateWarrantyMessage);
                            Assert.IsTrue(responseUpdateWarrantyMessage.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeBillingInfo_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeBillingInfo_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestBillingInfo = new SearchBilltoInfRequest { Header = header, TransferFlag = false };
                var responseBillingInfo = serviceClientCustomer.Proxy.SearchBilltoInf(requestBillingInfo);
                Assert.IsTrue(responseBillingInfo.IsSuccess);
                if (responseBillingInfo.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var BillingInfo in responseBillingInfo.Records)
                        {
                            SynchronizeBillingInfoRequest request = new SynchronizeBillingInfoRequest
                            {
                                Header = header,
                                Record = BillingInfo
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeBillingInfo(request);
                            Assert.IsTrue(response.IsSuccess);

                            BillingInfo.TransferFlag = true;
                            var requestUpdateBillingInfo = new UpdateBillingInfoRequest { Header = header, Record = BillingInfo };
                            var responseUpdateBillingInfo = serviceClientCustomer.Proxy.UpdateBilltoInf(requestUpdateBillingInfo);
                            Assert.IsTrue(responseUpdateBillingInfo.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeShopBillto_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeShopBillto_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestShopBillto = new SearchShopBilltoRequest { Header = header, TransferFlag = false };
                var responseShopBillto = serviceClientCustomer.Proxy.SearchShopBillto(requestShopBillto);
                Assert.IsTrue(responseShopBillto.IsSuccess);
                if (responseShopBillto.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var ShopBillto in responseShopBillto.Records)
                        {
                            SynchronizeShopBilltoRequest request = new SynchronizeShopBilltoRequest
                            {
                                Header = header,
                                Record = ShopBillto
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeShopBillto(request);
                            Assert.IsTrue(response.IsSuccess);

                            ShopBillto.TransferFlag = true;
                            var requestUpdateShopBillto = new UpdateShopBilltoRequest { Header = header, Record = ShopBillto };
                            var responseUpdateShopBillto = serviceClientCustomer.Proxy.UpdateShopBillto(requestUpdateShopBillto);
                            Assert.IsTrue(responseUpdateShopBillto.IsSuccess);
                        }
                    }
                }
            }
        }

        [TestMethod]
        public void SynchronizeMrp_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeMrp_Success"
            };

            using (ServiceClient<ICustomer> serviceClientCustomer = new ServiceClient<ICustomer>())
            {
                //1.Get all regions
                var requestMrp = new SearchMrpRequest { Header = header, TransferFlag = false };
                var responseMrp = serviceClientCustomer.Proxy.SearchMrp(requestMrp);
                Assert.IsTrue(responseMrp.IsSuccess);
                if (responseMrp.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var Mrp in responseMrp.Records)
                        {
                            SynchronizeMrpRequest request = new SynchronizeMrpRequest
                            {
                                Header = header,
                                Record = Mrp
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeMRP(request);
                            Assert.IsTrue(response.IsSuccess);

                            Mrp.TransferFlag = true;
                            var requestUpdateMrp = new UpdateMrpRequest { Header = header, Record = Mrp };
                            var responseUpdateMrp = serviceClientCustomer.Proxy.UpdateMRP(requestUpdateMrp);
                            Assert.IsTrue(responseUpdateMrp.IsSuccess);
                        }
                    }
                }
            }
        }
         
        [TestMethod]
        public void SynchronizeOrder_Success()
        {
            var header = new RequestHeaderRecord
            {
                ApplicationKey = SystemConfiguration.ApplicationKey,
                CallerName = "ModernChannel.Test.SynchronizeShopInfo_Test.SynchronizeOrder_Success"
            };

            using (ServiceClient<ISaleOut> serviceClientCustomer = new ServiceClient<ISaleOut>())
            {
                //1.Get all regions
                var requestOrder = new SearchOrdersRequest { Header = header, TransferFlag = false };
                var responseOrder = serviceClientCustomer.Proxy.SearchOrder(requestOrder);
                Assert.IsTrue(responseOrder.IsSuccess);
                if (responseOrder.IsSuccess)
                {
                    using (ServiceClient<IDataCenter> serviceClientDataCenter = new ServiceClient<IDataCenter>())
                    {
                        foreach (var Order in responseOrder.Records)
                        {
                            SynchronizeOrderRequest request = new SynchronizeOrderRequest
                            {
                                Header = header,
                                Record = Order
                            };
                            var response = serviceClientDataCenter.Proxy.SynchronizeOrder(request);
                            Assert.IsTrue(response.IsSuccess);

                            Order.TransferFlag = true;
                            var requestUpdateOrder = new UpdateOrderRequest { Header = header, Record = Order };
                            var responseUpdateOrder = serviceClientCustomer.Proxy.UpdateOrder(requestUpdateOrder);
                            Assert.IsTrue(responseUpdateOrder.IsSuccess);
                        }
                    }
                }
            }
        }
    }
}
